
#include "udp_socket.h"
#include <fcntl.h>

UdpSocket::UdpSocket()
{

}

void UdpSocket::Open()
{
    m_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);

}

void UdpSocket::SetOpt()
{
    int val = 1;
    setsockopt(m_socket_fd, SOL_SOCKET, SO_REUSEPORT, &val, sizeof(val));
}

void UdpSocket::SetNonBlocking()
{
    int old_mode = fcntl(m_socket_fd, F_GETFL);
    fcntl(m_socket_fd, F_SETFL, O_NONBLOCK | old_mode);
}